package com.gbx.ximalayating.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;

import com.gbx.ximalayating.R;
import com.gbx.ximalayating.adapter.TypeAdapter;
import com.gbx.ximalayating.entity.TypeEntity;

import java.util.ArrayList;
import java.util.List;

public class ClassifyImgActivity extends AppCompatActivity {

    private Toolbar tool;
    private TabLayout tab;
    private ViewPager pager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_classify_img);
        tool = (Toolbar) findViewById(R.id.tool);
        setSupportActionBar(tool);
        ActionBar actionBar = getSupportActionBar();

        pager = (ViewPager) findViewById(R.id.classify_img_vp);
        Intent intent = getIntent();
        String title = intent.getStringExtra("title");
        actionBar.setTitle(title);
        actionBar.setIcon(R.drawable.btn_back_orange);

        List<TypeEntity> list = new ArrayList<>();
        list.add(new TypeEntity("推荐","image"));
        list.add(new TypeEntity("商业","text"));
        list.add(new TypeEntity("成长","video"));
        list.add(new TypeEntity("最新","latest"));
        list.add(new TypeEntity("最新","latest"));
        list.add(new TypeEntity("最新","latest"));
        list.add(new TypeEntity("最新","latest"));
        list.add(new TypeEntity("最新","latest"));
        list.add(new TypeEntity("最新","latest"));
        list.add(new TypeEntity("最新","latest"));
        list.add(new TypeEntity("最新","latest"));
        list.add(new TypeEntity("最新","latest"));
        list.add(new TypeEntity("最新","latest"));
        list.add(new TypeEntity("最新","latest"));
        list.add(new TypeEntity("最新","latest"));
        pager.setAdapter(new TypeAdapter(getSupportFragmentManager(),list));
        tab = (TabLayout) findViewById(R.id.tab);
        tab.setupWithViewPager(pager);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        menu.add("已购");
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        return super.onOptionsItemSelected(item);
    }
}
